﻿using System;

using KingsSharp.Core.Data.Entity;
using CRM.Admin.Contracts.Model.Sys;
using System.Collections.Generic;
using KingsSharp.Core.Data;

namespace Property.Main.Services.EntityConfigurations.Sys
{
    public class AuthorizationConfiguration : EntityConfigurationBase<Authorization,Guid>
    {
        public AuthorizationConfiguration()
        {
            this.HasRequired(a => a.Role).WithMany(t => t.Auths).HasForeignKey(b => b.RoleId);
        }
    }

    //public class testCfg : EntityConfigurationBase<Student, int>
    //{
    //    public testCfg()
    //    {
    //        this.HasOptional(t => t.OtherInfo).WithOptionalDependent(b => b.Student);
    //    }
    //}


    public class Student: EntityBase<int>
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public DateTime EnrollmentDate { get; set; }

        // Navigation properties
        public virtual Address Address { get; set; }
        public virtual OtherInfo OtherInfo { get; set; }
        public virtual ICollection<Enrollment> Enrollments { get; set; }
    }

    public class Department : EntityBase<int>
    {
        public Department()
        {
            this.Courses = new HashSet<Course>();
        }
        // Primary key
        public int DepartmentID { get; set; }
        public string Name { get; set; }
        public decimal Budget { get; set; }
        public System.DateTime StartDate { get; set; }
        public int? Administrator { get; set; }

        // Navigation property
        public virtual ICollection<Course> Courses { get; private set; }
    }

    public class Course : EntityBase<int>
{
        public int CourseID { get; set; }
        public string Title { get; set; }
        public int Credits { get; set; }

        // Foreign key
        public int DepartmentID { get; set; }
        public string DepartmentName { get; set; }

        public int SomeDepartmentID { get; set; }

        // Navigation properties
        public virtual Department Department { get; set; }
        public virtual ICollection<Enrollment> Enrollments { get; set; }
        public virtual ICollection<Instructor> Instructors { get; set; }
    }

    public class Instructor : EntityBase<int>
    {
        public int InstructorID { get; set; }
        public string Name { get; set; }
        public DateTime HireDate { get; set; }

        // Navigation properties
        public virtual ICollection<Course> Courses { get; set; }
    }
    public class Enrollment : EntityBase<int>
    {
        public int EnrollmentID { get; set; }
        public int CourseID { get; set; }
        public int StudentID { get; set; }

        // Navigation property
        public virtual Course Course { get; set; }
        public virtual Student Student { get; set; }
    }

    public class Address : EntityBase<int>
    {
        public int AddressId { get; set; }
        public string HomeAddress { get; set; }
        public string LiveAddress { get; set; }

        // Navigation property
        public virtual Student Student { get; set; }
    }

    public class OtherInfo : EntityBase<int>
    {
        public int Id { get; set; }
        public string HomeAddress { get; set; }
        public string MailAddress { get; set; }
        public string PhoneNumber { get; set; }
        public string StudentID { get; set; }

        // Navigation property
        public virtual Student Student { get; set; }
    }
}
